import 'package:flutter/material.dart';

class AppColorScheme {
  static ColorScheme _createColorScheme(_ColorPalette palette) {
    return ColorScheme(
      brightness: palette.brightness,
      primary: palette.primary,
      onPrimary: palette.onPrimary,
      primaryContainer: palette.primaryContainer,
      onPrimaryContainer: palette.onPrimaryContainer,
      primaryFixed: palette.primaryFixed,
      primaryFixedDim: palette.primaryFixedDim,
      secondary: palette.secondary,
      onSecondary: palette.onSecondary,
      secondaryContainer: palette.secondaryContainer,
      onSecondaryContainer: palette.onSecondaryContainer,
      secondaryFixed: palette.secondaryFixed,
      tertiary: palette.tertiary,
      onTertiary: palette.onTertiary,
      tertiaryContainer: palette.tertiaryContainer,
      onTertiaryContainer: palette.onTertiaryContainer,
      tertiaryFixed: palette.tertiaryFixed,
      error: palette.error,
      onError: palette.onError,
      errorContainer: palette.errorContainer,
      surface: palette.surface,
      onSurface: palette.onSurface,
      outline: palette.outline,
    );
  }

  static ColorScheme get light {
    return _createColorScheme(_Light());
  }

  static ColorScheme get dark {
    return _createColorScheme(_Dark());
  }
}

abstract class _ColorPalette {
  Brightness get brightness;
  Color get primary;
  Color get onPrimary;
  Color get primaryContainer;
  Color get onPrimaryContainer;
  Color get primaryFixed;
  Color get primaryFixedDim;
  Color get secondary;
  Color get onSecondary;
  Color get secondaryContainer;
  Color get onSecondaryContainer;
  Color get secondaryFixed;
  Color get tertiary;
  Color get onTertiary;
  Color get tertiaryContainer;
  Color get onTertiaryContainer;
  Color get tertiaryFixed;
  Color get error;
  Color get onError;
  Color get errorContainer;
  Color get surface;
  Color get onSurface;
  Color get outline;
}

class _Light implements _ColorPalette {
  @override
  Brightness get brightness => Brightness.light;

  @override
  Color get primary => Color(0xFF1B215B);
  @override
  Color get onPrimary => primary.withOpacity(0.6);
  @override
  Color get primaryContainer => Colors.white;
  @override
  Color get onPrimaryContainer => primary;
  @override
  Color get primaryFixed => Color(0xFF6899E5);
  @override
  Color get primaryFixedDim => Color(0xFFDEF3FF);

  @override
  Color get secondary => primary.withOpacity(0.4);
  @override
  Color get onSecondary => primary;
  @override
  Color get secondaryContainer => primary.withOpacity(0.08);
  @override
  Color get onSecondaryContainer => primary;
  @override
  Color get secondaryFixed => Color(0xFF26C047);

  @override
  Color get tertiary => Color(0xFF8489B3);
  @override
  Color get onTertiary => Colors.black.withOpacity(0.4);
  @override
  Color get tertiaryContainer => primary.withOpacity(0.08);
  @override
  Color get onTertiaryContainer => Colors.white;
  @override
  Color get tertiaryFixed => Color(0xFFFD7A28);

  @override
  Color get error => Color(0xFFFA7267);
  @override
  Color get onError => Colors.white;
  @override
  Color get errorContainer => Color(0xFFF55C4C);

  @override
  Color get surface => Color(0xFFEBE8EF);
  @override
  Color get onSurface => Color(0xFFEBE8EF);

  @override
  Color get outline => primary.withOpacity(0.14);
}

class _Dark implements _ColorPalette {
  @override
  Brightness get brightness => Brightness.dark;

  @override
  Color get primary => Color(0xFFDEF3FF);
  @override
  Color get onPrimary => primary.withOpacity(0.6);
  @override
  Color get primaryContainer => Color(0xFF1B1B21);
  @override
  Color get onPrimaryContainer => Color(0xFF2375EE);
  @override
  Color get primaryFixed => Color(0xFF6899E5);
  @override
  Color get primaryFixedDim => primary;

  @override
  Color get secondary => primary.withOpacity(0.4);
  @override
  Color get onSecondary => Colors.white;
  @override
  Color get secondaryContainer => Color(0xFF8381CB).withOpacity(0.08);
  @override
  Color get onSecondaryContainer => Color(0xFF6899E5);
  @override
  Color get secondaryFixed => Color(0xFF26C047);

  @override
  Color get tertiary => Color(0xFF6C7085);
  @override
  Color get onTertiary => Colors.white.withOpacity(0.4);
  @override
  Color get tertiaryContainer => tertiary.withOpacity(0.08);
  @override
  Color get onTertiaryContainer => Colors.white.withOpacity(0.32);
  @override
  Color get tertiaryFixed => Color(0xFFFD7A28);

  @override
  Color get error => Color(0xFFFA7267);
  @override
  Color get onError => Colors.white;
  @override
  Color get errorContainer => Color(0xFFF55C4C);

  @override
  Color get surface => Color(0xFF121212);
  @override
  Color get onSurface => primary;

  @override
  Color get outline => Color(0xFF8381CB).withOpacity(0.14);
}
